package io.jpress.core.editorAddon;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class EditorAddonManager {

    private static final EditorAddonManager me = new EditorAddonManager();

    public static EditorAddonManager me() {
        return me;
    }


    private Map<String,EditorAddonInfo> editorAddonInfoMap = new ConcurrentHashMap<>();


    public void addEditorAddon(EditorAddonInfo editorAddonInfo){
        if (editorAddonInfoMap.containsKey(editorAddonInfo.getId())){
            throw new IllegalStateException("EditorAddon exists!");
        }
        editorAddonInfoMap.put(editorAddonInfo.getId(), editorAddonInfo);
    }


    public void removeEditorAddon(String id){
        editorAddonInfoMap.remove(id);
    }


    public Map<String, EditorAddonInfo> getEditorAddonInfoMap() {
        return editorAddonInfoMap;
    }



    public void setEditorAddonInfoMap(Map<String, EditorAddonInfo> editorAddonInfoMap) {
        this.editorAddonInfoMap = editorAddonInfoMap;
    }
}
